package com.jr.platform.generator;

import com.jr.platform.generator.CodeGen.CodeGenCore;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


/**
 * @author xy
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class CodeGeneration {
    private final CodeGenCore core;
    String json = "{\"interfaceName\": \"testInterface\",\n" +
            "\"header\": \"[{'headerKey':'Access_Token','headerValue':'111111111','headerType':'String'},{'headerKey':'Content-Type','headerValue':'application/xml','headerType':'String'}]\",\n" +
            "\"requestType\": \"get\",\n" +
            "\"params\": \"[{'paramsKey':'params1','paramsValue':'value1','paramsType':'String'},{'paramsKey':'params2','paramsValue':'value2','paramsType':'String'}]\",\n" +
            "\"result\": \"{'code':{'type':'string'},'message':{'type':'string'},'data':{'result1':{'type':'string'},'result2':{'type':'number'},'result3':{'type':'object','info':{'result31':{'type':'string'},'result32':{'type':'dateTime'},'result33':{'type':'list','info':{'result331':{'type':'string'},'result332':{'type':'string'}}},'result34':{'type':'list','info':{'result341':{'type':'string'},'result342':{'type':'list','info':{'result3421':{'type':'string'},'result3422':{'type':'dateTime'}}},'result343':{'type':'number'}}},'result35':{'type':'object','info':{'result351':{'type':'string'},'result352':{'type':'number'}}}}}}}\",\n" +
            "\"interfacePath\": \"/test/test1\",\n" +
            "\"relationTables\": \"\",\n" +
            "\"frontIds\": \"['1','2']\",\n" +
            "\"postIds\": \"['3','4']\"}";
    @Scheduled(cron = "0 21 15 * * ?")
    public void CodeGen(){
        core.contextLoads(json);
    }
}
